//
// Created by v on 2019/10/23 下午5:47.
// Copyright (c) 2019 jmdvirus All rights reserved.
//
//     ******          *             *--*
//       ||            *             |
//       ||  *--*--*---*  * *-********--*
//    * //   *  *  *   *\ / ||  |  |    |
//     **    *  *  *---* *  *   *--* *--*
//

#ifndef CUTEDEVICE_CMLANGUAGECONFIG_H
#define CUTEDEVICE_CMLANGUAGECONFIG_H

#include "config/cm_conf_ex.h"

class CMLanguage
{
  public:
    CMLanguage(const char *filename);

    int load();

    const std::string &getLang(const char *key);

  private:
    std::string     m_filename;
    CMConfigDataMap m_lang;
};

class CMLanguageConfig
{
  public:
    CMLanguageConfig();
    ~CMLanguageConfig();

    int load();

    const std::string &getLangZh(const char *key);
    const std::string &getLangEn(const char *key);

  private:
    const std::string &getLang(const char *lang, const char *key);

  private:
    std::map<std::string, CMLanguage *> m_langs;
};

class CMLanguageConfigGlobal
{
  public:
    static CMLanguageConfigGlobal *getInstace()
    {
        static CMLanguageConfigGlobal languageConfigGlobal;
        return &languageConfigGlobal;
    }

    CMLanguageConfig *getConfig() { return &m_config; }

  private:
    CMLanguageConfigGlobal(){};
    CMLanguageConfig m_config;
};

#endif // CUTEDEVICE_CMLANGUAGECONFIG_H
